<?php

namespace App\Http\Controllers\Domain;

use App\Helper;
use App\Http\Controllers\Controller;
use App\Models\Player;
use App\Models\Server;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class RecommendController extends Controller
{
    public $prefix='domain';

    public function index($domain,Request $request){
        $server=Server::where('domain',$domain)->first();
        Helper::setDataBaseConf('mysql_char',$server,'acore_characters');
        $p=json_decode( session('player'));
        $player=Player::getPlayer($server,$p->username);
        $id=$p->id;
        $url='http://'.$server->getDomain().'/register?rec='.$id;

        $list=Player::where('server_id',$server->id)->where('player_pid',$id)->orderBy('id','desc')->paginate(12);

        return view($this->prefix.'.recommend.index',compact('url','server','list','player'));
    }
}
